home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / X11R4 / cmds / X / ddx / mfb / RCS / mfbbstore.c,v < prev    next >
Encoding:
Text File  |  1990-02-15  |  4.5 KB  |  156 lines

  1. head     1.1;
  2. branch   ;
  3. access   ;
  4. symbols  ;
  5. locks    ; strict;
  6. comment  @ * @;
  7.  
  8.  
  9. 1.1
  10. date     90.02.14.19.57.58;  author tve;  state Exp;
  11. branches ;
  12. next     ;
  13.  
  14.  
  15. desc
  16. @Original X11R4 distribution
  17. @
  18.  
  19.  
  20.  
  21. 1.1
  22. log
  23. @Initial revision
  24. @
  25. text
  26. @/* Combined Purdue/PurduePlus patches, level 2.0, 1/17/89 */
  27. /***********************************************************
  28.  
  29. Copyright 1987 by the Regents of the University of California
  30. and the Massachusetts Institute of Technology, Cambridge, Massachusetts.
  31.  
  32.                         All Rights Reserved
  33.  
  34. Permission to use, copy, modify, and distribute this software and its 
  35. documentation for any purpose and without fee is hereby granted, 
  36. provided that the above copyright notice appear in all copies and that
  37. both that copyright notice and this permission notice appear in 
  38. supporting documentation, and that the names of Digital or MIT not be
  39. used in advertising or publicity pertaining to distribution of the
  40. software without specific, written prior permission.  
  41. ******************************************************************/
  42. /* $XConsortium: */
  43.  
  44. #include    "mfb.h"
  45. #include    "X.h"
  46. #include    "mibstore.h"
  47. #include    "regionstr.h"
  48. #include    "scrnintstr.h"
  49. #include    "pixmapstr.h"
  50. #include    "windowstr.h"
  51.  
  52. /*-
  53.  *-----------------------------------------------------------------------
  54.  * mfbSaveAreas --
  55.  *    Function called by miSaveAreas to actually fetch the areas to be
  56.  *    saved into the backing pixmap. This is very simple to do, since
  57.  *    mfbDoBitblt is designed for this very thing. The region to save is
  58.  *    already destination-relative and we're given the offset to the
  59.  *    window origin, so we have only to create an array of points of the
  60.  *    u.l. corners of the boxes in the region translated to the screen
  61.  *    coordinate system and fetch the screen pixmap out of its devPrivate
  62.  *    field....
  63.  *
  64.  * Results:
  65.  *    None.
  66.  *
  67.  * Side Effects:
  68.  *    Data are copied from the screen into the pixmap.
  69.  *
  70.  *-----------------------------------------------------------------------
  71.  */
  72. void
  73. mfbSaveAreas(pPixmap, prgnSave, xorg, yorg)
  74.     PixmapPtr          pPixmap;      /* Backing pixmap */
  75.     RegionPtr          prgnSave;     /* Region to save (pixmap-relative) */
  76.     int                  xorg;            /* X origin of region */
  77.     int                  yorg;            /* Y origin of region */
  78. {
  79.     register DDXPointPtr pPt;
  80.     DDXPointPtr        pPtsInit;
  81.     register BoxPtr    pBox;
  82.     register int    i;
  83.     int            numRects;
  84.     
  85.     numRects = REGION_NUM_RECTS(prgnSave);
  86.     pPtsInit = (DDXPointPtr)ALLOCATE_LOCAL(numRects * sizeof(DDXPointRec));
  87.     if (!pPtsInit)
  88.     return;
  89.     
  90.     pBox = REGION_RECTS(prgnSave);
  91.     pPt = pPtsInit;
  92.     i = numRects;
  93.     Duff(i, pPt->x = pBox->x1 + xorg; pPt->y = pBox->y1 + yorg; pPt++; pBox++);
  94.  
  95.     mfbDoBitblt((DrawablePtr)pPixmap->drawable.pScreen->devPrivate,
  96.         (DrawablePtr)pPixmap,
  97.         GXcopy,
  98.         prgnSave,
  99.         pPtsInit);
  100.  
  101.     DEALLOCATE_LOCAL(pPtsInit);
  102. }
  103.  
  104. /*-
  105.  *-----------------------------------------------------------------------
  106.  * mfbRestoreAreas --
  107.  *    Function called by miRestoreAreas to actually fetch the areas to be
  108.  *    restored from the backing pixmap. This is very simple to do, since
  109.  *    mfbDoBitblt is designed for this very thing. The region to restore is
  110.  *    already destination-relative and we're given the offset to the
  111.  *    window origin, so we have only to create an array of points of the
  112.  *    u.l. corners of the boxes in the region translated to the pixmap
  113.  *    coordinate system and fetch the screen pixmap out of its devPrivate
  114.  *    field....
  115.  *
  116.  * Results:
  117.  *    None.
  118.  *
  119.  * Side Effects:
  120.  *    Data are copied from the pixmap into the screen.
  121.  *
  122.  *-----------------------------------------------------------------------
  123.  */
  124. void
  125. mfbRestoreAreas(pPixmap, prgnRestore, xorg, yorg)
  126.     PixmapPtr          pPixmap;      /* Backing pixmap */
  127.     RegionPtr          prgnRestore;     /* Region to restore (screen-relative)*/
  128.     int                  xorg;            /* X origin of window */
  129.     int                  yorg;            /* Y origin of window */
  130. {
  131.     register DDXPointPtr pPt;
  132.     DDXPointPtr        pPtsInit;
  133.     register BoxPtr    pBox;
  134.     register int    i;
  135.     int            numRects;
  136.     
  137.     numRects = REGION_NUM_RECTS(prgnRestore);
  138.     pPtsInit = (DDXPointPtr)ALLOCATE_LOCAL(numRects*sizeof(DDXPointRec));
  139.     if (!pPtsInit)
  140.     return;
  141.     
  142.     pBox = REGION_RECTS(prgnRestore);
  143.     pPt = pPtsInit;
  144.     i = numRects;
  145.     Duff(i, pPt->x = pBox->x1 - xorg; pPt->y = pBox->y1 - yorg; pPt++; pBox++);
  146.  
  147.     mfbDoBitblt((DrawablePtr)pPixmap,
  148.         (DrawablePtr)pPixmap->drawable.pScreen->devPrivate,
  149.         GXcopy,
  150.         prgnRestore,
  151.         pPtsInit);
  152.  
  153.     DEALLOCATE_LOCAL(pPtsInit);
  154. }
  155. @
  156.